home *** CD-ROM | disk | FTP | other *** search
/ Kit PC World De Ampliacion De Windows 95 / Kit PC World de ampliacion de Windows 95.iso / internet / sweeper / samples / docobj / framer.h < prev    next >
C/C++ Source or Header  |  1995-12-04  |  6KB  |  221 lines

  1. /*
  2.  * FRAMER.H
  3.  * Document Objects Framer
  4.  * Definitions of classes, constants, etc.
  5.  * Includes in-line implementation of CHourGlass, CWindow
  6.  *
  7.  * Copyright (c)1995 Microsoft Corporation, All Rights Reserved
  8.  * Kraig Brockschmidt, kraigb@microsoft.com
  9.  */
  10.  
  11.  
  12. #ifndef _FRAMER_H_
  13. #define _FRAMER_H_
  14.  
  15. #define INC_OLE2
  16. #include <windows.h>
  17. #include <ole2.h>
  18. #include <ole2ver.h>
  19. #include <oledlg.h>
  20. #include <docobj.h>
  21.  
  22. #include <tchar.h>
  23. #ifdef UNICODE
  24. #include <wchar.h>
  25. #endif
  26.  
  27. extern "C"
  28.     {
  29.     #include <commdlg.h>
  30.     }
  31.  
  32.  
  33. #include "resource.h"
  34.  
  35.  
  36. //DeleteInterfaceImp calls 'delete' and NULLs the pointer
  37. #define DeleteInterfaceImp(p)\
  38.             {\
  39.             if (NULL!=p)\
  40.                 {\
  41.                 delete p;\
  42.                 p=NULL;\
  43.                 }\
  44.             }
  45.  
  46.  
  47. //ReleaseInterface calls 'Release' and NULLs the pointer
  48. #define ReleaseInterface(p)\
  49.             {\
  50.             IUnknown *pt=(IUnknown *)p;\
  51.             p=NULL;\
  52.             if (NULL!=pt)\
  53.                 pt->Release();\
  54.             }
  55.  
  56.  
  57.  
  58. class CHourglass;
  59. class CFrame;
  60. class CSite;
  61.  
  62.  
  63. /**
  64.  ** CFrame encapsulates a main application window
  65.  **/
  66.  
  67. //FRAMEWIN.CPP:  Standard window procedure and AboutProc
  68. LRESULT APIENTRY FrameWndProc(HWND, UINT, WPARAM, LPARAM);
  69. LRESULT APIENTRY ClientWndProc(HWND, UINT, WPARAM, LPARAM);
  70. BOOL    APIENTRY AboutProc(HWND, UINT, WPARAM, LPARAM);
  71.  
  72. #define CBFRAMEWNDEXTRA     sizeof(LONG)
  73. #define FRAMEWL_STRUCTURE   0
  74.  
  75. #define CBCLIENTWNDEXTRA    sizeof(LONG)
  76. #define CLIENTWL_STRUCTURE  0
  77.  
  78. #define SZCLASSFRAME        TEXT("Frame")
  79. #define SZCLASSCLIENT       TEXT("Client")
  80.  
  81.  
  82. //FRAME.CPP:  Frame object that creates a main window
  83.  
  84. class CFrame : public IOleInPlaceFrame
  85.     {
  86.     //Let our window procedure look in our private variables.
  87.     friend LRESULT APIENTRY FrameWndProc(HWND, UINT, WPARAM, LPARAM);
  88.     friend LRESULT APIENTRY ClientWndProc(HWND, UINT, WPARAM, LPARAM);
  89.  
  90.     protected:
  91.         HINSTANCE       m_hInst;            //Task instance
  92.         HWND            m_hWnd;             //Window handle of the window
  93.         ULONG           m_cRef; 
  94.  
  95.         HINSTANCE       m_hInstPrev;        //WinMain parameters
  96.         LPTSTR          m_pszCmdLine;
  97.         int             m_nCmdShow;        
  98.  
  99.         HMENU          *m_phMenu;           //Popup menu handles
  100.         HACCEL          m_hAccel;           //Accelerators
  101.         HWND            m_hWndClient;       //Client area window
  102.  
  103.         BOOL            m_fInitialized;     //OleInitialize called?
  104.         IStorage       *m_pIStorage;        //Temp file for all needs
  105.         DWORD           m_dwIDCounter;      //For site IDs
  106.  
  107.         //For menu merging
  108.         HMENU           m_hMenuOrg;         //Original menu
  109.         HMENU           m_hMenuTop;            //Currently shown menu
  110.         HMENU            m_hMenuHelp;        //Special Help menu
  111.         BOOL            m_fUsingOurHelp;    //Help menu in use?
  112.         BOOL            m_fInObjectHelp;    //Object's menu found?
  113.         BOOL            m_fOurMenuShowing;  //Our menu up?        
  114.  
  115.         //Other object needs
  116.         BOOL            m_fHaveObject;      //For menu enabling
  117.         HWND            m_hWndObj;            //UI Active object
  118.  
  119.         class CSite    *m_pSite;            //Site holding object        
  120.         BORDERWIDTHS    m_bwIP;             //In-place tool allocations
  121.         BOOL            m_fInContextHelp;   //In context help mode?
  122.  
  123.         IOleInPlaceActiveObject *m_pIOleIPActiveObject;
  124.  
  125.     protected:
  126.         BOOL    RegisterAllClasses(void);        
  127.         LRESULT OnCommand(HWND, WPARAM, LPARAM);        
  128.         BOOL    OpenDialog(LPTSTR, UINT);
  129.         BOOL    CreateObject(LPTSTR);
  130.         void    ResizeClientWindow(UINT, UINT, UINT, UINT);
  131.  
  132.     public:
  133.         CFrame(HINSTANCE, HINSTANCE, LPSTR, int);
  134.         ~CFrame(void);
  135.  
  136.         inline HINSTANCE Instance(void)
  137.             { return m_hInst; }
  138.  
  139.         inline HWND      Window(void)
  140.             { return m_hWnd; }        
  141.  
  142.         inline HACCEL    Accelerators(void)
  143.             { return m_hAccel; }        
  144.         
  145.         BOOL    Init(UINT, int, int, int, int);
  146.         WPARAM  MessageLoop(void);
  147.         void    Close();        
  148.  
  149.         //IOleInPlaceFrame implementation
  150.         STDMETHODIMP         QueryInterface(REFIID, void **);
  151.         STDMETHODIMP_(ULONG) AddRef(void);
  152.         STDMETHODIMP_(ULONG) Release(void);
  153.  
  154.         STDMETHODIMP         GetWindow(HWND *);
  155.         STDMETHODIMP         ContextSensitiveHelp(BOOL);
  156.         STDMETHODIMP         GetBorder(LPRECT);
  157.         STDMETHODIMP         RequestBorderSpace(LPCBORDERWIDTHS);
  158.         STDMETHODIMP         SetBorderSpace(LPCBORDERWIDTHS);
  159.         STDMETHODIMP         SetActiveObject(LPOLEINPLACEACTIVEOBJECT
  160.                                  , LPCOLESTR);
  161.         STDMETHODIMP         InsertMenus(HMENU, LPOLEMENUGROUPWIDTHS);
  162.         STDMETHODIMP         SetMenu(HMENU, HOLEMENU, HWND);
  163.         STDMETHODIMP         RemoveMenus(HMENU);
  164.         STDMETHODIMP         SetStatusText(LPCOLESTR);
  165.         STDMETHODIMP         EnableModeless(BOOL);
  166.         STDMETHODIMP         TranslateAccelerator(LPMSG, WORD);
  167.     };
  168.  
  169.  
  170. typedef CFrame *PCFrame;
  171.  
  172.  
  173.  
  174. /**
  175.  ** CHourglass:  Manages the hourglass and mouse capture
  176.  **/
  177.  
  178. class CHourglass
  179.     {
  180.     protected:
  181.         HWND            m_hWndCapture;      //Window with capture
  182.         HCURSOR         m_hCur;             //Cursor held.
  183.  
  184.     public:
  185.         CHourglass(void)
  186.             {
  187.             m_hCur=SetCursor(LoadCursor(NULL, IDC_WAIT));
  188.             m_hWndCapture=NULL;
  189.             return;
  190.             }
  191.  
  192.         CHourglass(HWND hWnd)
  193.             {
  194.             m_hCur=SetCursor(LoadCursor(NULL, IDC_WAIT));
  195.  
  196.             if (NULL!=hWnd)
  197.                 {
  198.                 m_hWndCapture=hWnd;
  199.                 SetCapture(hWnd);
  200.                 }
  201.  
  202.             return;
  203.             }
  204.  
  205.         ~CHourglass(void)
  206.             {
  207.             if (NULL!=m_hWndCapture)
  208.                 ReleaseCapture();
  209.  
  210.             SetCursor(m_hCur);
  211.             return;
  212.             }
  213.     };
  214.  
  215. typedef CHourglass *PCHourglass;
  216.  
  217.  
  218. #include "site.h"
  219.  
  220. #endif //_FRAMER_H_
  221.